package selenium;

import org.testng.annotations.Test;
import selenium.model.Film;
import selenium.model.User;

import static org.junit.Assert.assertTrue;

public class FilmSearch extends selenium.pages.TestBase {
    @Test
    public void testFilmAdd() throws Exception {
        // Log in
        User user = new User("editor", "1");
        app.getUserHelper().loginAs(user);
        assertTrue(app.getUserHelper().isLoggedInAs(user));
        app.getNavigationHelper().gotoInternalMainPage();
        app.getNavigationHelper().gotoAddMoviePage();

        // Search film
        Film film = new Film();
        film.setName("Godzilla");
        int filmsFound = app.getFilmHelper().searchFilm(film.getName());
        assertTrue(filmsFound > 0);
        app.getUserHelper().logout();
    }

    @Test
    public void testFilmAddError() throws Exception {
        // Log in
        User user = new User("editor", "1");
        app.getUserHelper().loginAs(user);
        assertTrue(app.getUserHelper().isLoggedInAs(user));

        // Search film
        Film film = new Film();
        film.setName("Kavabunga");
        int filmsFound = app.getFilmHelper().searchFilm(film.getName());
        assertTrue(filmsFound == 0);
    }
}